define(function (require, exports, module) {

    require("apps/grid");
    require("apps/flexpaper");
    require("apps/jplayer");

    exports.init = function(ctx, uuid, config){
        var page = new $.PageDomFactory(uuid);
        page.getJqDom("version").combobox({
            editable: false,
            onSelect: function(record){
                location.href = ctx + "/app/api/document/detail?id="+ record.value + "&admin=" + config.admin;
            }
        });

        $("#flash_viewer").flexpaper({
            config: {
                SWFFile:WE.contextPath + "/print/"+ config.directory + "/" + config.result
            }
        });

        var path = ctx + "/play" + config.path;
        $("#jquery_jplayer_1").jPlayer({
            ready: function () {
                $(this).jPlayer("setMedia", {
                    title: config.docName,
                    m4v: path,
                    ogv: path,
                    webmv: path,
                    poster: ctx + "/static/js/jPlayer-2.9.1/dist/Big_Buck_Bunny_Trailer_480x270.png"
                });
            },
            swfPath: ctx + "/static/js/jPlayer-2.9.1/dist/jplayer",
            supplied: "webmv, ogv, m4v",
            size: {
                width: "640px",
                height: "360px",
                cssClass: "jp-video-360p"
            },
            useStateClassSkin: true,
            autoBlur: false,
            smoothPlayBar: true,
            keyEnabled: true,
            remainingDuration: true,
            toggleDuration: true
        });

    }
});